package com.mrd.gtimpframe.service;

import com.mrd.gtimpframe.repository.StartRunnerMapper;
import com.mrd.redis.JedisClientClusterImpl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

/**
 * Created by dark on 17/8/7.
 */
@Service
public class StartRunnerBiz {

    @Resource
    private StartRunnerMapper startRunnerMapper;

    @Resource
    private JedisClientClusterImpl jedisClientCluster;

    public List<Map<String, Object>> selectGoodsVerificationList() {
        List<Map<String, Object>> result = startRunnerMapper.selectGoodsVerificationList();
        return result;
    }

    public void selectAndUpdateGoodsCodeCache() {
//        List<Map<String, Object>> result = this.selectGoodsVerificationList();
//        if (CollectionUtils.isNotEmpty(result)) {
//            List<Map<String, Object>> tempList = new ArrayList<>();
//            for (Map<String, Object> map : result) {
//                JSONObject jsonObject = JSONObject.fromObject(map);
//                Map<String, Object> tempMap = new HashedMap();
//                tempMap.put(map.get("CODE_T").toString() + map.get("CODE_S").toString(), jsonObject.toString());
//                tempList.add(tempMap);
//            }
//            if (CollectionUtils.isNotEmpty(tempList)) {
//                jedisClientCluster.delete("goodsCode");
//                jedisClientCluster.rightPushAll("goodsCode", tempList, null, null);
//            }
//        }
    }
}
